<%@page import="com.system.dao.RoleDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../common.jsp" %>
<%
	RoleDao dao = new RoleDao();
	List<Map<String,Object>> list = dao.getRoleList();
	pageContext.setAttribute("list", list);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'userEdit.jsp' starting page</title>
    <script type="text/javascript">
    
    	var userId = "${param.id}";
    	
    	$().ready(function(){
			if(userId != "")
			{
				ajax.remoteCall("com.system.dao.UserDao:findUser",[userId],function(reply){
					
					Form.bindForm("winForm",reply.getResult());
				});
			}
    	});
    	
    	function doSave()
    	{
    		if(doCheck())
    		{
    			var map = Form.formToBean("winForm");
        		map.id = userId;
        		ajax.remoteCall("com.system.dao.UserDao:update",[map],function(reply){
        			var result = reply.getResult();
        			alert(result.value);
        			if(result.type == "success")
        			{
        				var dlg = Dialog.getInstance("view");
        	    		dlg.getParam("window").mygrid.reload();
        	    		dlg.close();
        			}
        		});
    		}
    	}
    	
    	function doCheck()
    	{
    		if($.trim($("#name").val()) == "")
    		{
    			alert("用户名不能为空");
    			return false;
    		}
    		
    		if($("#campus").val() == "")
    		{
    			alert("请选择所属校区");
    			return false;
    		}
    		
    		if($("#roles").val() == null)
    		{
    			alert("请选择角色");
    			return false;
    		}
    		return true;
    	}
    </script>
  </head>
  
  <body style="overflow: hidden;">
   <form id="winForm" name="winForm">
   		<input name="id" type="hidden" value="${param.id}">
  		<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
			<tr height="40px" valign="bottom">
				<td width="120px" align="right"><font color="#FF0000">*</font>&nbsp;用户名：</td>
				<td width="160px"><input id="name" name="name" type="text" class="textbox" style="width: 140px"/></td>
				<td width="120px" align="right">性别：</td>
				<td width="180px">
					<input name="sex" type="radio" value="0" checked/>男&nbsp;&nbsp;&nbsp;
					<input name="sex" type="radio" value="1"/>女
				</td>
			</tr>
			<tr height="50px">
				<td width="120px" align="right"><font color="#FF0000">*</font>所属校区：</td>
				<td width="160px">
					<select id="campus" name="campus" style="width: 140px">
						<option value="">--请选择--</option>
						<option value="0">校本部</option>
						<option value="1">白云校区</option>
						<option value="2">北校区</option>
						<option value="3">西校区</option>
					</select>
				</td>
				<td width="130px" align="right">联系电话：</td>
				<td width="180px"><input name="telephone" type="text" class="textbox" style="width: 140px"/></td>
			</tr>
			<tr height="60px" valign="top">
				<td width="120px" align="right">角色：</td>
				<td colspan="3">
					<select id="roles" name="roles" multiple="multiple" style="width: 94%;height: 120px;">
						<c:forEach items="${list}" var="obj">
							<option value="${obj['id']}">${obj['name']}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td width="120px" align="right"><img src="${path}/images/tip.png" border="0" width="20px" height="15px" /></td>
				<td colspan="3"><font color="green" style="font-size: 13px">温馨提示：按住ctrl可以选择多个岗位</font></td>
			</tr>
  		</table>
	</form>
  </body>
</html>
